package mspbots.teams.client.core.data.groups;

import com.fasterxml.jackson.databind.JsonNode;
import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

/**
 * GroupsController
 *
 * @author <a href="https://github.com/vnobo">Alex bob</a>
 * @date Created by 2020/8/31
 */
@Log4j2
@RestController
@RequiredArgsConstructor
@RequestMapping("groups/{tenantId}")
public class GroupsController {

    private final GroupsServiceImpl groupsService;

    @GetMapping("find")
    public Flux<JsonNode> find(@PathVariable Long tenantId) {
        return this.groupsService.find(tenantId);
    }

    @GetMapping("channels/{groupId}")
    public Flux<JsonNode> channels(@PathVariable Long tenantId,
                                   @PathVariable String groupId) {
        return this.groupsService.channels(tenantId, groupId);
    }

    @GetMapping("members/{groupId}")
    public Flux<JsonNode> members(@PathVariable Long tenantId,
                                  @PathVariable String groupId) {
        return this.groupsService.members(tenantId, groupId);
    }
}
